<style type="text/css" title="text/css">
.div_stl001 label.cabinet
{
    width: 100px;
    height: 28px;
    background: url(<?php echo base_url()?>image/select_ads.jpg) 0 0 no-repeat;
    display: block;
    overflow: hidden;
    cursor: pointer;
	margin-bottom:5px;
    padding:0;    
}

.div_stl001 label.cabinet input.file
{
    position: relative;
    height: 100%;
    width: auto;
    opacity: 0;
    -moz-opacity: 0;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
}
</style>


<?php $this->load->view(TEMPLATE_NAME.'/admin/header'); ?>

<?php $this->load->view(TEMPLATE_NAME.'/admin/side_left');?>
<script src="<?php  echo base_url(); ?>js/jquery-1.4.2.js"></script>
<script src="<?php  echo base_url(); ?>js/jquery.validate.js"></script>

<script src="<?php echo base_url(); ?>js/ajaxfileupload.js"></script>
<script src="<?php echo base_url(); ?>js/si.files.js"></script>

  
<script type="text/javascript">// function upload jquery
function load_image()
{
var imgpath = document.getElementById('fileToUpload').value;

if(imgpath != "")
{
// code to get File Extension..

var arr1 = new Array;

arr1 = imgpath.split("\\");

var len = arr1.length;

var img1 = arr1[len-1];

var filext = img1.substring(img1.lastIndexOf(".")+1);

// Checking Extension

if(filext == "jpg" || filext == "jpeg" || filext == "gif" )

document.getElementById('fileToUpload').src = imgpath;

else

{
alert("Invalid Image Format Selected");
//document.getElementById('fileToUpload').value = "";

return false;

}

}

}
function ajaxFileUpload(){
 
 
    $("#loading")
    .ajaxStart(function(){
        $(this).show();
    })
    .ajaxComplete(function(){
        $(this).hide();
    });
    var check_img=load_image();
    if(check_img == false)
    {
        return false;
    }
    
    $.ajaxFileUpload({
        url:'<?php echo site_url('ajax_upload/upload_directory_image/upload/banners')?>',
        secureuri:false,
        fileElementId:'fileToUpload',
        dataType: 'json',
        success: function (data, status){
            if(typeof(data.error) != 'undefined')
            { 
                if(data.error != ''){
                    $("#info").html('<span >'+data.error+"</span>");
                }else{ 
                    $("#info").html('<img src="<?php echo base_url();?>uploads/banners/'+data.msg
                    +'"  />'
                    +'<input type="hidden" name="upload" id="upload" value="'+data.msg +'">');
                   
                }
            }
        },
        error: function (data, status, e){
            $("#info").html(e);
        }
    })  
         
    return false;
}


 $(document).ready(function(){
 
       $("#clear_logo").click(function(){
        
      var str=$("#upload").val();
    $.ajax({
       type: "POST",
       url: '<?php echo site_url('admin/banners/logo_delete'); ?>',
       data: "filename="+str,
       success: function(msg){
        
              <?php if($ban_detail['ban_placement']=='1'){ ?>
                 $("#info").html('<img src="<?php echo base_url()?>image/sponsorcrimepage-right.jpg" width="200" height="250">'
            + '<input type="hidden" name="upload" value="">');
            // alert( "Data Saved: " + msg );
        <?php    }
            if($ban_detail['ban_placement']=='2'){?>
                 $("#info").html('<img src="<?php echo base_url()?>image/sponsorcrimepage-right.jpg" width="590" height="70">'
            + '<input type="hidden" name="upload" value="">');
            // alert( "Data Saved: " + msg );
          <?php  }?>
                
               }
           
            });
      
        });
  
     
   $('#ban_action').validate({
   rules:{
       
        upload:{required:true},
       
        ban_link:{required:true,url:true},
        ban_tag:'required'
                
    },
    messages:{
       
        upload:'Please upload banner image ',
       
        ban_link:'Please enter  valid link.',
         ban_tag:'Please enter  tag.'
        
    }
   });
  
 
   
    }); 
   </script>

<script type="text/javascript">

 
    String.prototype.capitalize = function(){
   return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
  };

</script>
<div class="page adminpage" style="width: 790px;">
<b class="purple">Banner</b>
<hr />
<b class="f13 black">Add/Edit Default Banner</b>
<hr />
<div class="clear"></div>

<!--<div class="clear"></div> -->

<?php
$right_display='none';
$buttom_display='none';
$placement_display = 'none';

if($ban_detail['ban_placement'] == '1')
{
$placement_display = 'block';
 $right_display = 'block';

}
if($ban_detail['ban_placement'] == '2')
{
$placement_display = 'block';
 $buttom_display = 'block'; 

}

/* ban_action form */
$attributes = array('name' => 'ban_action','id' => 'ban_action','class' => 'ban_action'); // for styling
echo form_open('admin/banners/action_def',$attributes); ?>


<div class="clear"></div>
  

<!--/right ban date ends-->  
<!-- Banner name start-->  
<div class="formstep" style="margin-bottom: 0;">
   <!-- <strong>Banner Name: </strong> <span class="purple">*</span>-->
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
<?php 
$ban_name_input = array(
	'id'=>'ban_name',
	'name'=>'ban_name',
	'style' => 'width:580px',
    
	);
    if( $ban_detail['ban_name'])
    {$ban_name_val = $ban_detail['ban_name'];}
    else
    {$ban_name_val = set_value('ban_name');}

echo form_hidden($ban_name_input, $ban_name_val);
?>
</div>
<?php  //echo form_error('ban_name'); ?>
<!-- Banner name end-->
<!-- Banner placement start-->

 <div class="formstep" style="margin-bottom: 0;">
   <span class="purple"> <strong>Banner placement: </strong></span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
<div class="radios box_p" style="display:<?php echo $right_display;?>">

    
	<div class="input_form002"> 
		<strong class="purple">Right Banner</strong> 
	<span> - Banner must be 200x250 (height is variable - but width must be 200px)</span>
    </div>
    
	<div class="clear"></div>
    
</div>
<div class="clear"></div>
<div class="radios box_p" style="display:<?php echo $buttom_display;?>">
  
	<div class="input_form002"> 
		<strong class="purple">Bottom Banner</strong> 
        <span> - Banner must be 590x70px</span>
	</div>
    
	<div class="clear"></div>
    
</div>
<label for="ban_placement" generated="true" class="error" style="display:  none;">Please select placement.</label>
<div class="clear"></div>
<div class="div_stl001" style="display:block">

<!-- Banner right uploader starts-->
	 <!-- <p class="gray_font"><strong>Logo</strong> <span class="purple">(optional)</span></p>-->
     <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)):?>
      <input type="file" class="file" id="fileToUpload" name="fileToUpload" onchange="return ajaxFileUpload();" /><br />
 <?php else:  ?>
    <label class="cabinet"> 
        <input type="file" class="file" id="fileToUpload" name="fileToUpload" onchange="return ajaxFileUpload();" />
    </label>
<?php endif;?>
         <!---image holder-->
         <img id="loading" src="<?php echo base_url()?>image/loading_blue.gif" style="display:none;position:absolute;z-index:1000;left: 350px; top: 280px;" />   
    <div id="info" >
       <?php if(!empty($ban_detail['ban_image']) &&  file_exists('./uploads/banners/'.$ban_detail['ban_image'])){
      
        ?>
            <img src="<?php echo base_url()?>uploads/banners/<?php echo $ban_detail['ban_image']?>" >
            <input type="hidden" name="upload" value="<?php echo $ban_detail['ban_image']?>">
           
        <?php } else{?>
        
        <div class="right_banner" style="display:<?php echo $right_display;?>">
            <img width="200" height="250" src="<?php echo base_url()?>image/sponsorcrimepage-right.jpg">  
             </div>
             
            <div class="buttom_banner" style="display:<?php echo $buttom_display;?>">  
            <img width="590" height="70" src="<?php echo base_url()?>image/sponsorcrimepage-footer.jpg">  
             </div>     
        <?php } ?>
</div>
 

       <!--image holder-->
         
         

<p class="gray_font"><strong>Upload Banner logo</strong></p>
<a href="javascript:void(0)" id="clear_logo"><span class="purple">clear current upload</span></a>

<!-- Banner right uploader end-->
</div>
<div class="clear" style="height: 5px;"></div>
<div class="radios box_p"><span class="purple">Banner:</span>(Upload GIF or JPG)</div>

<div class="clear"></div>
<!-- Banner placement end-->
 
<hr />
<div class="formstep" style="margin-bottom: 0;">
    <strong>Banner link: </strong> <span class="purple">*(website link or e-mail link)</span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
     <div class="formstep" style="margin-bottom:0">
    <?php
    if($ban_detail['ban_link'])
    {$ban_link_val=$ban_detail['ban_link'];}
    else
    {$ban_link_val=set_value('ban_link');}
    
     echo form_input(array('name'=>'ban_link','id'=>'ban_link'),$ban_link_val,'style="width:580px"'); ?>
    <?php  echo form_error('ban_link'); ?>
    </div>
    </div>
    </div>
	<div class="clear"></div>
 <!-- Banner link end-->  
  <!-- Banner tag start -->   
 <div class="formstep" style="margin-bottom: 0;">
    <strong>ALT tag: </strong> <span class="purple">*</span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
     <div class="formstep" style="margin-bottom:0">
    <?php
    if($ban_detail['ban_tag'])
    {$ban_tag_val=$ban_detail['ban_tag'];}
    else
    {$ban_tag_val=set_value('ban_tag');}
    
     echo form_input(array('name'=>'ban_tag','id'=>'ban_tag'),$ban_tag_val,'style="width:580px"'); ?>
    <?php  echo form_error('ban_tag'); ?>
    </div>
    </div>
    </div>
	<div class="clear"></div>
  <!-- Banner tag end --> 

 <div class="" style="padding-top: 5px;padding-left:200px">
     <input type="hidden" name="ban_id" value="<?php echo ($ban_detail['ban_id']!='')? $ban_detail['ban_id'] : ''; ?>" />
    	<?php echo form_submit('ban_action_submit', 'Submit'); ?> 
		<?php echo form_close(); ?>
    </div>
    <div class="clear"></div>




    <?php //$this->load->view(TEMPLATE_NAME.'/admin/footer_menu');?>
</div>

<?php $this->load->view(TEMPLATE_NAME.'/admin/footer');?>